﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.Paint.DefinePaintBrush.CApSolidValidator
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using EngineeringInternalExtension;
using Tecnomatix.Engineering;


namespace DnProcessSimulateCommands.Paint.DefinePaintBrush;

internal class CApSolidValidator : CApBaseValidator
{
  public override bool IsValidObject(ITxObject obj, out string errorMessage)
  {
    bool flag = false;
    errorMessage = (string) null;
    if (obj == null)
      errorMessage = DnProcessSimulateCommands.Paint.DefinePaintBrush.Resources.StringTable.INVALID_SOLID_ERROR;
    else if (obj is ITx2Or3DimensionalGeometry)
    {
      ITxComponent parentComponent = this.GetParentComponent(obj);
      if (!TxEngineeringDataInternal.ObjectIsResourceInstance((ITxObject) parentComponent))
      {
        errorMessage = DnProcessSimulateCommands.Paint.DefinePaintBrush.Resources.StringTable.PARENT_ISNOT_RESOURCE;
        return flag;
      }
      if (parentComponent != null)
      {
        if (this._parent == null)
          this._parent = parentComponent;
        if (parentComponent == this._parent)
        {
          if ((obj as ITxDetailedRepresentation).Preserved || this._parent.RepresentationType == 6)
          {
            flag = true;
          }
          else
          {
            errorMessage = DnProcessSimulateCommands.Paint.DefinePaintBrush.Resources.StringTable.PRESERVED_SOLID_ERROR;
            this._parent = (ITxComponent) null;
          }
        }
        else
          errorMessage = DnProcessSimulateCommands.Paint.DefinePaintBrush.Resources.StringTable.INVALID_SOLID_PARENT_ERROR;
      }
      else
      {
        errorMessage = DnProcessSimulateCommands.Paint.DefinePaintBrush.Resources.StringTable.INVALID_SOLID_PARENT_ERROR;
        this._parent = (ITxComponent) null;
      }
    }
    else
      errorMessage = DnProcessSimulateCommands.Paint.DefinePaintBrush.Resources.StringTable.INVALID_SOLID_ERROR;
    return flag;
  }
}
